﻿using JTActiveSafety.Gateway.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Text;

namespace JTActiveSafety.Gateway.InMemoryMQ
{
    public static class JTActiveSafetyInMemoryMQExtensions
    {
        public static IJTActiveSafetyGatewayBuilder AddMsgProducer(this IJTActiveSafetyGatewayBuilder builder)
        {
            builder.JTActiveSafetyBuilder.Services.TryAddSingleton<JTActiveSafetyMsgChannel>();
            builder.JTActiveSafetyBuilder.Services.AddSingleton<IJTActiveSafetyMsgProducer, JTActiveSafetyMsgProducer>();
            return builder;
        }

        public static IJTActiveSafetyGatewayBuilder AddMsgConsumer(this IJTActiveSafetyGatewayBuilder builder)
        {
            builder.JTActiveSafetyBuilder.Services.TryAddSingleton<JTActiveSafetyMsgChannel>();
            builder.JTActiveSafetyBuilder.Services.AddSingleton<IJTActiveSafetyMsgConsumer, JTActiveSafetyMsgConsumer>();
            return builder;
        }
    }
}
